<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/commons/taglibs.jsp"%>
<form id="inputForm" class="well form-inline" action="${ctx}/adoms/order/save" method="post">
	<input type="hidden" name="id" value="${order.id}" />
	<input id="type" name="type" type="hidden" value="1" />
	<table class="table table-striped table-bordered table-condensed">
		<thead>
			<i class="icon-flag"></i>
			<strong>订单表单</strong>
		</thead>
		<tr>
			<td class="span2">订单编号:</td>
			<td>
				<span class="tBlue">${order.code}</span>
				<input id="code" name="code" type="hidden" value="${order.code}" size="30" maxlength="80" />
			</td>
		</tr>
		<tr>
			<td>发货部门:</td>
			<td>
				<span class="tBlue">${order.departmentTarget.name}</span>
				<input id="departmentTarget" name="departmentTarget.id" type="hidden" value="${order.departmentTarget.id}" size="30" maxlength="80" />
			</td>
		</tr>
		<tr>
			<td>商品:</td>
			<td>
				<span class="tBlue">${order.marchandise.name}</span>
				<input id="marchandise" name="marchandise.id" type="hidden" value="${order.marchandise.id}" size="30" maxlength="80" />
			</td>
		</tr>
		<tr>
			<td>单价:</td>
			<td>
				<span class="tBlue">
					￥
					<span id="mPrice" class="tRed">${order.marchandise.price}</span>
					元
				</span>
			</td>
		</tr>
		<tr>
			<td class="span2">订单名称:</td>
			<td>
				<input id="name" class="span4" name="name" type="text" value="${order.name}" size="30" maxlength="80" />
			</td>
		</tr>
		<tr>
			<td>订购数量:</td>
			<td>
				<input id="goodsNumber" class="span1" name="goodsNumber" type="text" value="${order.goodsNumber}" size="30" maxlength="4" />
				(件)
			</td>
		</tr>
		<tr>
			<td>总价:</td>
			<td>
				<input id="totalCost" name="totalCost" class="span2" readonly="readonly" type="text" value="${order.totalCost}" size="30" maxlength="8" />
				(元)
			</td>
		</tr>
		<tr>
			<td>订单受理人:</td>
			<td>
				<span>${order.orderChargeUser}</span>
				<input id="orderChargeUser" name="orderChargeUser" type="hidden" value="${order.orderChargeUser}" size="30" maxlength="80" />
			</td>
		</tr>
		<tr>
			<td>受理时间:</td>
			<td>
				<span>${order.receivedTime}</span>
				<c:if test="${order.receivedTime != null}">
					<input datepicker id="receivedTime" name="receivedTime" type="hidden" value="${order.receivedTime}" size="30" maxlength="80" />
				</c:if>
			</td>
		</tr>
		<tr>
			<td>下单时间:</td>
			<td>
				<span class="tBlue">${order.orderCreateTime}</span>
				<input datepicker id="orderCreateTime" name="orderCreateTime" type="hidden" value="${order.orderCreateTime}" size="30" maxlength="80" />
			</td>
		</tr>
		<tr>
			<td>状态:</td>
			<td>
				<select id="status" name="status">
					<option value="${order.status}">${order.status.value}</option>
					<option value="ORDER_HAS_RECEIPT">已收货</option>
					<option value="ORDER_HAS_CANCELED">已取消</option>
				</select>
			</td>
		</tr>
		<tr>
			<td>收货部门:</td>
			<td>
				<span class="tBlue">${order.department.name}</span>
				<input id="department" name="department.id" type="hidden" value="${order.department.id}" size="30" maxlength="80" />
			</td>
		</tr>
		<tr>
			<td>联系人:</td>
			<td>
				<input id="createUser" name="createUser" type="text" value="${order.createUser}" size="30" maxlength="80" />
			</td>
		</tr>
		<tr>
			<td>联系电话:</td>
			<td>
				<input id="phone" name="phone" type="text" value="${order.phone}" size="30" maxlength="80" />
			</td>
		</tr>
		<tr>
			<td>备注:</td>
			<td>
				<textarea id="memo" name="memo" rows="4" maxlength="200" class="span6">${order.memo}</textarea>
			</td>
		</tr>
		<tr>
			<td colspan="2" align="center">
				<input class="btn btn-primary span1" type="submit" value="提 交" />
				&nbsp;
				<input class="btn span1 btn-info" type="button" value="返 回" back="back" />
			</td>
		</tr>
	</table>
</form>
<script>
	$(document).ready(function() {
		//为inputForm注册validate函数
		$("#inputForm").validate({
			rules : {
				totalCost : "required",
				phone : "required",
				orderCreateTime : "required",
				status : "required",
				department : "required",
				memo : "required",
				departmentTarget : "required",
				createUser : "required",
				goodsNumber : {
					required : true,
					number : true
				}
			}
		});
		//计算总价
		$("#goodsNumber").keyup(function() {
			var number = parseInt($(this).val());
			var price = parseFloat($("#mPrice").html());
			var cost = number * price;
			$("#totalCost").val(cost.toFixed(2));
		});
	});
</script>